$(function () {
    $('body').on('mouseover','.list li',function () {
        $(this).children('.data_delete2').show();
    });
    $('body').on('mouseout','.list li',function () {
        $(this).children('.data_delete2').hide();
    });
})

$(document).ready(function(){
    function doDelete(id,range){
        $.ajax({
            url: '/buyer/del-record',
            type: 'get',
            dataType: 'json',
            data: {history_id:id,date_range:range},
            success:function (data) {
                if (data.code == 0) {
                    location.reload();
                }else{
                    $.MsgBox.Alert('温馨提示','删除失败');
                }
            }
        })
    }
    
    $('body').on('click','.del-today',function(){
        doDelete(0,[window.today,window.tomorrow]);
    });

    $('body').on('click','.del-earlier',function(){
        doDelete(0,['1970-01-01',today]);
    });


    $('body').on('click','.data_delete2',function(){
         var id = parseInt($(this).attr('data-id'));
         if(id){
            doDelete(id,[]);
         }
    });

});